/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component,Fragment} from 'react';
import { Form, Input, Radio, Select, Icon, Tabs, Alert, Button, InputNumber, Modal, message } from 'antd';

import {connect} from 'dva';
import gold_groud from './../../images/valve_small.png'
import gold_groud2 from './../../images/valve2_small.jpg'
import yali from './../../images/famen.png';
import request from '@/utils/request';
import Zmage from 'react-zmage'
import P0 from '../../images/valve.png';
import styles from './index.less';
import find from 'lodash/find'
import setting from './setting.json'
const Option=Select.Option
const FormItem = Form.Item;
const {TabPane} = Tabs;
class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);

    this.state = {
      img:'',
      all_vendors:[],
      all_protocols:[],
      templateId:'',
      hardware_configs: {}
    };
  }
  componentDidMount() {

      const response = setting
      if (response.status === 200) {
        console.log('response',response)
        this.setState({
          templateId:String(response.data.data.template)
        })
        console.log('response.data.data.hardware_configs', response.data.data.hardware_configs)
        if (response.data.data.hardware_configs.device) {
          for (let i = 0; i < response.data.data.hardware_configs.device.length; i++) {
            response.data.data.hardware_configs.device[i].upload_interval = response.data.data.hardware_configs.device[i].upload_interval / 60
          }
        }
        if (response.data.data.hardware_configs.ball_valve) {
          for (let i = 0; i < response.data.data.hardware_configs.ball_valve.length; i++) {
            if (response.data.data.hardware_configs.ball_valve[i].mode === 0) {
              response.data.data.hardware_configs.ball_valve[i].normal_upload_interval = 60
              response.data.data.hardware_configs.ball_valve[i].alarm_upload_interval = 30
            }
            if (response.data.data.hardware_configs.ball_valve[i].mode === 1) {
              response.data.data.hardware_configs.ball_valve[i].alarm_upload_interval = 30
            }
            if (!response.data.data.hardware_configs.ball_valve[i].alias) {
              response.data.data.hardware_configs.ball_valve[i].alias = '球阀';
            }

          }
        }
        if (response.data.data.hardware_configs.modbus) {
          for (let i = 0; i < response.data.data.hardware_configs.modbus.length; i++) {
            if (response.data.data.hardware_configs.modbus[i].type === 0) {
              response.data.data.hardware_configs.modbus[i].upload_interval = 300
              response.data.data.hardware_configs.modbus[i].baudrate = 9600
              response.data.data.hardware_configs.modbus[i].parity = 2
            }
            if (!response.data.data.hardware_configs.modbus[i].alias) {
              response.data.data.hardware_configs.modbus[i].alias = 'modbus';
            }
            if (!response.data.data.hardware_configs.modbus[i].type) {
              response.data.data.hardware_configs.modbus[i].type = 0;
            }
          }
        }
        if (response.data.data.hardware_configs.digital_input) {
          for (let i = 0; i < response.data.data.hardware_configs.digital_input.length; i++) {
            if (response.data.data.hardware_configs.digital_input[i].type === 0) {
              response.data.data.hardware_configs.digital_input[i].normal_upload_interval = 60
              response.data.data.hardware_configs.digital_input[i].alarm_upload_interval = 30
            }
            if (!response.data.data.hardware_configs.digital_input[i].alias) {
              response.data.data.hardware_configs.digital_input[i].alias = '数字输入';
            }
          }
        }
        if (response.data.data.hardware_configs.sensor) {
          for (let i = 0; i < response.data.data.hardware_configs.sensor.length; i++) {
            if (response.data.data.hardware_configs.sensor[i].type === 0) {
              response.data.data.hardware_configs.sensor[i].normal_upload_interval = 60
              response.data.data.hardware_configs.sensor[i].alarm_upload_interval = 30
            }
            if (!response.data.data.hardware_configs.sensor[i].alias) {
              response.data.data.hardware_configs.sensor[i].alias = '传感器';
            }
            if (!response.data.data.hardware_configs.sensor[i].type) {
              response.data.data.hardware_configs.sensor[i].type = 0;
            }
          }
        }
        if (response.data.data.hardware_model === 'RTU-03') {
          response.data.data.hardware_configs.modbus_03 = response.data.data.hardware_configs.modbus
        } else if (response.data.data.hardware_model === 'RTU-04') {
          response.data.data.hardware_configs.modbus_04 = response.data.data.hardware_configs.modbus
        } else {

        }
        this.setState({
          origin_hardware_model: response.data.data.hardware_model,
          hardware_model: response.data.data.hardware_model,
          hardware_configs: response.data.data.hardware_configs,
          alarm_contact_numbers: response.data.data.alarm_contact_numbers
        })
      }


  }

  changeConfig = (newConfig) => {
    this.setState({
      hardware_configs: {...this.state.hardware_configs, ...newConfig}
    })
  }

  renderValveForm2 = (key) => {
    console.log('templateId',this.state.templateId)
    const that = this;
    let img=''
    if(this.state.templateId==='1'){
      img=gold_groud2
    }
    return <Form layout="inline" style={{paddingBottom:'50px'}}>
      <Fragment>
        <div style={{display: 'flex'}}>
          <div style={{paddingTop: '5px', marginRight: '10px'}}>站点类型 :</div>
          <div style={{flex: '1'}}><Select value={this.state.templateId} onChange={(e) => {
            this.setState({
              templateId: e
            }, function () {
              if (e === '1') {
                this.state.hardware_configs.sensor[0].type = '';
                // this.state.hardware_configs.sensor[0].alias = '压力传感器1';
                // this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                // this.state.hardware_configs.sensor[0].alarm = 1;
                // this.state.hardware_configs.sensor[0].over = 0.9;
                // this.state.hardware_configs.sensor[0].under = 0.2;
                // this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                // this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;

                this.state.hardware_configs.sensor[1].type = '';
                // this.state.hardware_configs.sensor[1].alias = '压力传感器2';
                // this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                // this.state.hardware_configs.sensor[1].alarm = 1;
                // this.state.hardware_configs.sensor[1].over = '0.78';
                // this.state.hardware_configs.sensor[1].under = 0.2;
                // this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                // this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;


                this.state.hardware_configs.sensor[2].type = '';
                // this.state.hardware_configs.sensor[2].alias = '压力传感器3';
                // this.state.hardware_configs.sensor[2].normal_upload_interval = 900;
                // this.state.hardware_configs.sensor[2].alarm = 1;
                // this.state.hardware_configs.sensor[2].over = '0.63';
                // this.state.hardware_configs.sensor[2].under = 0.2;
                // this.state.hardware_configs.sensor[2].fluctuation_value = 0.05;
                // this.state.hardware_configs.sensor[2].alarm_upload_interval = 30;

                // this.state.hardware_configs.sensor[3].mode = 0;
                // this.state.hardware_configs.sensor[3].type = '';


                this.state.hardware_configs.digital_input[0].type='';
                // this.state.hardware_configs.digital_input[0].alias='水流指示器';
                // this.state.hardware_configs.digital_input[0].normal_upload_interval=900;
                // this.state.hardware_configs.digital_input[0].alarm = 1;
                // this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;

                this.state.hardware_configs.ball_valve[0].mode=0
                // this.state.hardware_configs.ball_valve[0].alias='阀门'
                // this.state.hardware_configs.ball_valve[0].normal_upload_interval=900;

                this.state.hardware_configs.modbus_03[0].type='SCL-61D-GTE50'
                this.state.hardware_configs.modbus_03[0].alias='流量计'
                this.state.hardware_configs.modbus_03[0].slave_address=1
                this.state.hardware_configs.modbus_03[0].upload_interval=900
                this.state.hardware_configs.modbus_03[0].baudrate='9600'
                this.state.hardware_configs.modbus_03[0].parity=2

                this.setState({
                  hardware_configs:this.state.hardware_configs,
                })
              }
            })
          }}>
            <Option value={'0'}>未知</Option>
            <Option value={'1'}>双阀减压阀井</Option>
          </Select></div>
        </div>

        {
          Boolean(Number(this.state.templateId))&&
          <Fragment>
            <div style={{display: 'flex',marginTop:'10px'}}>
              <div style={{paddingTop: '5px', marginRight: '10px'}}>站点图片 :</div>
              <div style={{flex: '1'}}>
                <Zmage  src={img} alt="" style={{width:300}}/>
              </div>
            </div>
            <div className={styles.box_item} style={{paddingTop: '12px'}}>
              <Tabs size='small' defaultActiveKey={'device'} style={{background: '#f2f2f2'}}>
                <TabPane tab={'设备信息'} key={'device'}>

                  <Form.Item
                    label="数据上传间隔(分钟)"
                  >
                    <InputNumber
                      value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                      onChange={(e) => {
                        if (!this.state.hardware_configs.device) {
                          this.state.hardware_configs.device = []
                        }
                        if (this.state.hardware_configs.device.length < 1) {
                          this.state.hardware_configs.device[0] = {}
                          this.state.hardware_configs.device[0].upload_interval = e
                        } else {
                          this.state.hardware_configs.device.splice(0, 1, {
                            ...this.state.hardware_configs.device[0],
                            upload_interval: e
                          })
                        }
                        this.changeConfig({device: this.state.hardware_configs.device})
                      }}
                    />
                  </Form.Item>

                </TabPane>
              </Tabs>
            </div>
            <div className={styles.box_item} style={{paddingTop: '12px'}}>
              <Tabs size='small' defaultActiveKey={'传感器-1'} style={{background: '#f2f2f2'}}>
                {
                  [{name: '传感器-1'}, {name: '传感器-2'}, {name: '传感器-3'}, {name: '传感器-4'}].map((item, index) => {
                    if(!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index]&& this.state.hardware_configs.sensor[index].type )){
                      return  false
                    }
                   return <TabPane tab={item.name} key={item.name}>

                      {
                        <Fragment><Form.Item
                          label='设备类型'>
                        {/*  <Select
                            disabled
                            onChange={(e) => {
                              console.log(e);
                              if (!this.state.hardware_configs.sensor) {
                                this.state.hardware_configs.sensor = [];
                              }
                              if (this.state.hardware_configs.sensor.length < 4) {
                                if (this.state.hardware_configs.sensor[index]) {
                                  this.state.hardware_configs.sensor[index].type = e;
                                } else {
                                  this.state.hardware_configs.sensor[index] = {};
                                  this.state.hardware_configs.sensor[index].type = e;
                                }
                              } else {
                                this.state.hardware_configs.sensor.splice(index, 1, {
                                  ...this.state.hardware_configs.sensor[index],
                                  type: e,
                                });
                              }
                              this.changeConfig({sensor: this.state.hardware_configs.sensor});
                            }}
                            style={{width: 170}}
                            value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type}>
                            {[{name: '0-1.6Mpa压力传感器', key: 'sensor001'}, {name: '无', key: 0}].map((item, key) => {
                              return (
                                <Option key={key}
                                        value={item.key}>{item.name}</Option>
                              );
                            })}
                          </Select>*/}
                          <span>
                            {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && find([{name: '0-1.6Mpa压力传感器', key: 'sensor001'}, {name: '无', key: 0}],o=>o.key===this.state.hardware_configs.sensor[index].type)&&
                            find([{name: '0-1.6Mpa压力传感器', key: 'sensor001'}, {name: '无', key: 0}],o=>o.key===this.state.hardware_configs.sensor[index].type).name}
                          </span>
                        </Form.Item>
                          <br/>
                        </Fragment>
                      }
                      {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                      [{name: '别名', key: 'alias'}].map((item2, index2) => {
                        return <Fragment key={index2}>
                          <Form.Item

                            label={item2.name}
                          >

                        {/*    <Input
                              disabled
                              style={{width: '140px'}}
                              value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                              onChange={(e) => {
                                if (!this.state.hardware_configs.sensor) {
                                  this.state.hardware_configs.sensor = [];
                                }
                                if (this.state.hardware_configs.sensor.length < 4) {
                                  if (this.state.hardware_configs.sensor[index]) {
                                    this.state.hardware_configs.sensor[index][item2.key] = e.target.value;
                                  } else {
                                    this.state.hardware_configs.sensor[index] = {};
                                    this.state.hardware_configs.sensor[index][item2.key] = e.target.value;
                                  }
                                } else {
                                  this.state.hardware_configs.sensor.splice(index, 1, {
                                    ...this.state.hardware_configs.sensor[index],
                                    [item2.key]: e.target.value
                                  });
                                }


                                this.changeConfig({sensor: this.state.hardware_configs.sensor});
                              }}
                            />*/}
                            <span>
                              {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                            </span>
                          </Form.Item>

                          <br/>

                        </Fragment>;

                      })
                      }
                      {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                      [{name: '上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                        return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                          <Fragment key={index2}>
                            <Form.Item

                              label={item2.name}
                            >
                              <InputNumber
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index][item2.key] = e;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index][item2.key] = e;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      [item2.key]: e,
                                    });
                                  }


                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                              />
                            </Form.Item>

                            <br/>

                          </Fragment>;

                      })
                      }
                      {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                      <Fragment><Form.Item
                        label="是否预警"
                      >
                        <Radio.Group onChange={(e) => {
                          if (!this.state.hardware_configs.sensor) {
                            this.state.hardware_configs.sensor = [];
                          }
                          if (this.state.hardware_configs.sensor.length < 4) {
                            if (this.state.hardware_configs.sensor[index]) {
                              this.state.hardware_configs.sensor[index].alarm = e.target.value;
                            } else {
                              this.state.hardware_configs.sensor[index] = {};
                              this.state.hardware_configs.sensor[index].alarm = e.target.value;
                            }
                          } else {
                            this.state.hardware_configs.sensor.splice(index, 1, {
                              ...this.state.hardware_configs.sensor[index],
                              alarm: e.target.value,
                            });
                          }
                          this.changeConfig({sensor: this.state.hardware_configs.sensor});
                        }}
                                     value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                          <Radio value={1}>报警</Radio>
                          <Radio value={0}>不报警</Radio>
                        </Radio.Group>
                      </Form.Item>
                        <br/>
                      </Fragment>
                      }

                      {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                      [{name: '过压值(Mpa)', key: 'over'}, {
                        name: '欠压值(Mpa)',
                        key: 'under',
                      }, {
                        name: '波动值(Mpa)',
                        key: 'fluctuation_value',
                      }].map((item2, index2) => {
                        return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                          <Fragment key={index2}>
                            <Form.Item

                              label={item2.name}
                            >
                              <InputNumber
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index][item2.key] = e;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index][item2.key] = e;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      [item2.key]: e,
                                    });
                                  }


                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                              />
                            </Form.Item>
                            {index2 === 2 && <br/>}
                          </Fragment>;

                      })
                      }
                      {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                      [{
                        name: '报警间隔(秒)',
                        key: 'alarm_upload_interval',
                      }].map((item2, index2) => {
                        return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                          <Fragment key={index2}>
                            <Form.Item

                              label={item2.name}
                            >
                              <InputNumber
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index][item2.key] = e;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index][item2.key] = e;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      [item2.key]: e,
                                    });
                                  }


                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                              />
                            </Form.Item>

                          </Fragment>;

                      })
                      }


                    </TabPane>;
                  })
                }
              </Tabs>
            </div>

            <div className={styles.box_item}>
              <Tabs size='small' defaultActiveKey={'数字输入-1'} style={{background: '#f2f2f2'}}>
                {
                  [{name: '数字输入-1'}, {name: '数字输入-2'}].map((item, index) => {
                    if(!(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index]&& this.state.hardware_configs.digital_input[index].type )){
                      return  false
                    }
                    return <TabPane tab={item.name} key={item.name}>
                      <Fragment><Form.Item
                        label='设备类型'>
                     {/*   <Select
                          disabled
                          onChange={(e) => {
                            console.log(e)
                            if (!this.state.hardware_configs.digital_input) {
                              this.state.hardware_configs.digital_input = []
                            }
                            if (this.state.hardware_configs.digital_input.length < 2) {
                              if (this.state.hardware_configs.digital_input[index]) {
                                this.state.hardware_configs.digital_input[index].type = e
                              } else {
                                this.state.hardware_configs.digital_input[index] = {}
                                this.state.hardware_configs.digital_input[index].type = e
                              }
                            } else {
                              this.state.hardware_configs.digital_input.splice(index, 1, {
                                ...this.state.hardware_configs.digital_input[index],
                                type: e
                              })
                            }
                            this.changeConfig({digital_input: this.state.hardware_configs.digital_input})
                          }}
                          style={{width: 170}}
                          value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].type}>
                          {[{key: 'flow_indicator', name: '水流指示器'}, {key: 0, name: '无'}].map((item, key) => {
                            return (
                              <Option key={key}
                                      value={item.key}>{item.name}</Option>
                            )
                          })}
                        </Select>*/}
                        <span>
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && find([{key: 'flow_indicator', name: '水流指示器'}, {key: 0, name: '无'}],o=>o.key===this.state.hardware_configs.digital_input[index].type)&&
                            find([{key: 'flow_indicator', name: '水流指示器'}, {key: 0, name: '无'}],o=>o.key===this.state.hardware_configs.digital_input[index].type).name}
                          </span>
                      </Form.Item>
                        <br/>
                        {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                        [{name: '别名', key: 'alias'}].map((item2, index2) => {
                          return <Fragment key={index2}>
                            <Form.Item

                              label={item2.name}
                            >
                              {/*<Input
                                disabled
                                style={{width: '140px'}}
                                value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = [];
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index][item2.key] = e.target.value;
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {};
                                      this.state.hardware_configs.digital_input[index][item2.key] = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      [item2.key]: e.target.value
                                    });
                                  }


                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                }}
                              />*/}
                              <span>
                                {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                              </span>
                            </Form.Item>

                            <br/>

                          </Fragment>;

                        })
                        }
                      </Fragment>
                      {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                      [{name: '上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                        return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                          <Fragment key={index2}>
                            <Form.Item

                              label={item2.name}
                            >
                              <InputNumber
                                value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = []
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index][item2.key] = e
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {}
                                      this.state.hardware_configs.digital_input[index][item2.key] = e
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      [item2.key]: e
                                    })
                                  }


                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input})
                                }}
                              />
                            </Form.Item>
                            <br/>
                          </Fragment>

                      })
                      }
                      {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                      <Fragment><Form.Item
                        label="是否预警"
                      >
                        <Radio.Group onChange={(e) => {
                          if (!this.state.hardware_configs.digital_input) {
                            this.state.hardware_configs.digital_input = []
                          }
                          if (this.state.hardware_configs.digital_input.length < 2) {
                            if (this.state.hardware_configs.digital_input[index]) {
                              this.state.hardware_configs.digital_input[index].alarm = e.target.value
                            } else {
                              this.state.hardware_configs.digital_input[index] = {}
                              this.state.hardware_configs.digital_input[index].alarm = e.target.value
                            }
                          } else {
                            this.state.hardware_configs.digital_input.splice(index, 1, {
                              ...this.state.hardware_configs.digital_input[index],
                              alarm: e.target.value
                            })
                          }
                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input})
                        }}
                                     value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].alarm}>
                          <Radio value={1}>报警</Radio>
                          <Radio value={0}>不报警</Radio>
                        </Radio.Group>
                      </Form.Item>
                        <br/>
                      </Fragment>
                      }
                      {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) && Boolean(this.state.hardware_configs.digital_input[index].alarm) &&
                      [{
                        name: '报警间隔(秒)',
                        key: 'alarm_upload_interval'
                      }].map((item2, index2) => {
                        return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                          <Fragment key={index2}>
                            <Form.Item

                              label={item2.name}
                            >
                              <InputNumber
                                value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = []
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index][item2.key] = e
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {}
                                      this.state.hardware_configs.digital_input[index][item2.key] = e
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      [item2.key]: e
                                    })
                                  }


                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input})
                                }}
                              />
                            </Form.Item>

                          </Fragment>

                      })
                      }


                    </TabPane>
                  })
                }
              </Tabs>
            </div>
            <div className={styles.box_item}>
              <Tabs size='small' defaultActiveKey={'球阀-1'} style={{background: '#f2f2f2'}}>
                {
                  [{name: '球阀-1'}, {name: '球阀-2'}].map((item, index) => {
                    if(!(this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index].mode)){
                      return  false
                    }
                    return <TabPane tab={item.name} key={item.name}>
                      <Fragment><Form.Item
                        label='设备模式'>
                       {/* <Select
                          disabled
                          onChange={(e) => {
                            console.log(e)
                            if (!this.state.hardware_configs.ball_valve) {
                              this.state.hardware_configs.ball_valve = []
                            }
                            if (this.state.hardware_configs.ball_valve.length < 2) {
                              if (this.state.hardware_configs.ball_valve[index]) {
                                this.state.hardware_configs.ball_valve[index].mode = e
                              } else {
                                this.state.hardware_configs.ball_valve[index] = {}
                                this.state.hardware_configs.ball_valve[index].mode = e
                              }
                            } else {
                              this.state.hardware_configs.ball_valve.splice(index, 1, {
                                ...this.state.hardware_configs.ball_valve[index],
                                mode: e
                              })
                            }
                            this.changeConfig({ball_valve: this.state.hardware_configs.ball_valve})
                          }}
                          style={{width: 170}}
                          value={this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index].mode}>
                          {[{key: 3, name: '关联数字输入'}, {key: 2, name: '关联传感器'},
                            {key: 1, name: '手动'}, {key: 0, name: '无'}].map((item, key) => {
                            return (
                              <Option key={key}
                                      value={item.key}>{item.name}</Option>
                            )
                          })}
                        </Select>*/}
                        <span>
                            {this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index].mode && find([{key: 3, name: '关联数字输入'}, {key: 2, name: '关联传感器'},
                              {key: 1, name: '手动'}, {key: 0, name: '无'}],o=>o.key===this.state.hardware_configs.ball_valve[index].mode)&&
                            find([{key: 3, name: '关联数字输入'}, {key: 2, name: '关联传感器'},
                              {key: 1, name: '手动'}, {key: 0, name: '无'}],o=>o.key===this.state.hardware_configs.ball_valve[index].mode).name}
                          </span>
                      </Form.Item>
                        <br/>
                        {this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && Boolean(this.state.hardware_configs.ball_valve[index].mode) &&
                        [{name: '别名', key: 'alias'}].map((item2, index2) => {
                          return <Fragment key={index2}>
                            <Form.Item

                              label={item2.name}
                            >
                              {/*<Input
                                disabled
                                style={{width: '140px'}}
                                value={this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index][item2.key]}
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.ball_valve) {
                                    this.state.hardware_configs.ball_valve = [];
                                  }
                                  if (this.state.hardware_configs.ball_valve.length < 2) {
                                    if (this.state.hardware_configs.ball_valve[index]) {
                                      this.state.hardware_configs.ball_valve[index][item2.key] = e.target.value;
                                    } else {
                                      this.state.hardware_configs.ball_valve[index] = {};
                                      this.state.hardware_configs.ball_valve[index][item2.key] = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.ball_valve.splice(index, 1, {
                                      ...this.state.hardware_configs.ball_valve[index],
                                      [item2.key]: e.target.value
                                    });
                                  }


                                  this.changeConfig({ball_valve: this.state.hardware_configs.ball_valve});
                                }}
                              />*/}
                              <span>
                                {this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index][item2.key]}
                              </span>
                            </Form.Item>

                            <br/>

                          </Fragment>;

                        })
                        }
                      </Fragment>
                      {
                        this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && Boolean(this.state.hardware_configs.ball_valve[index].mode) &&
                        [{name: 'parameter1', key: 'parameter1'}, {
                          name: 'parameter2',
                          key: 'parameter2'
                        }, {name: 'parameter3', key: 'parameter3'}, {name: 'parameter4', key: 'parameter4'},
                          {name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                          name: '报警间隔(秒)',
                          key: 'alarm_upload_interval'
                        }].map((item2, index2) => {
                          let name = item2.name;
                          if (this.state.hardware_configs.ball_valve[index].mode === 1) {
                            if (item2.key === 'parameter1') {
                              name = '输出状态'
                            }
                            if (item2.key === 'alarm_upload_interval') {
                              name = ''
                            }
                          }
                          if (this.state.hardware_configs.ball_valve[index].mode === 2) {
                            if (item2.key === 'parameter1') {
                              name = '传感器索引'
                            }
                            if (item2.key === 'parameter2') {
                              name = '正常输出状态'
                            }
                            if (item2.key === 'parameter3') {
                              name = '过压输出状态'
                            }
                            if (item2.key === 'parameter4') {
                              name = '欠压输出状态'
                            }
                          }
                          if (this.state.hardware_configs.ball_valve[index].mode === 3) {
                            if (item2.key === 'parameter1') {
                              name = '数字输入索引'
                            }
                            if (item2.key === 'parameter2') {
                              name = '正常输出状态'
                            }
                            if (item2.key === 'parameter3') {
                              name = '报警输出状态'
                            }
                          }
                          return <Fragment key={index2}>
                            {
                              (name.indexOf('parameter') === -1 && name) && <Form.Item

                                label={name}
                              >
                                {
                                  name.indexOf('状态') >= 0 ?
                                    <Select
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.ball_valve) {
                                          this.state.hardware_configs.ball_valve = []
                                        }
                                        if (this.state.hardware_configs.ball_valve.length < 2) {
                                          if (this.state.hardware_configs.ball_valve[index]) {
                                            this.state.hardware_configs.ball_valve[index][item2.key] = e
                                          } else {
                                            this.state.hardware_configs.ball_valve[index] = {}
                                            this.state.hardware_configs.ball_valve[index][item2.key] = e
                                          }
                                        } else {
                                          this.state.hardware_configs.ball_valve.splice(index, 1, {
                                            ...this.state.hardware_configs.ball_valve[index],
                                            [item2.key]: e
                                          })
                                        }
                                        this.changeConfig({ball_valve: this.state.hardware_configs.ball_valve})
                                      }}

                                      style={{width: 100}}
                                      value={this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index][item2.key]}>
                                      {[{key: 1, name: '开'}, {key: 0, name: '关'}].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        )
                                      })}
                                    </Select>
                                    : <InputNumber
                                      value={this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.ball_valve) {
                                          this.state.hardware_configs.ball_valve = []
                                        }
                                        if (this.state.hardware_configs.ball_valve.length < 2) {
                                          if (this.state.hardware_configs.ball_valve[index]) {
                                            this.state.hardware_configs.ball_valve[index][item2.key] = e
                                          } else {
                                            this.state.hardware_configs.ball_valve[index] = {}
                                            this.state.hardware_configs.ball_valve[index][item2.key] = e
                                          }
                                        } else {
                                          this.state.hardware_configs.ball_valve.splice(index, 1, {
                                            ...this.state.hardware_configs.ball_valve[index],
                                            [item2.key]: e
                                          })
                                        }
                                        this.changeConfig({ball_valve: this.state.hardware_configs.ball_valve})
                                      }}
                                    />

                                }

                              </Form.Item>
                            }
                            {index2 === 3 && <br/>}
                          </Fragment>

                        })
                      }


                    </TabPane>
                  })
                }
              </Tabs>
            </div>
            <div className={styles.box_item}>
              <Tabs size='small' defaultActiveKey={'Modbus-1'} style={{background: '#f2f2f2'}}>
                {
                  [{name: 'Modbus-1'}, {name: 'Modbus-2'}].map((item, index) => {
                    if(!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index]&& this.state.hardware_configs.modbus_03[index].type )){
                      return  false
                    }
                    return <TabPane tab={item.name} key={item.name}>
                      <Fragment><Form.Item
                        label='设备类型'>
                      {/*  <Select
                          disabled
                          onChange={(e) => {
                            console.log(e);
                            if (!this.state.hardware_configs.modbus_03) {
                              this.state.hardware_configs.modbus_03 = [];
                            }
                            if (this.state.hardware_configs.modbus_03.length < 2) {
                              if (this.state.hardware_configs.modbus_03[index]) {
                                this.state.hardware_configs.modbus_03[index].type = e;
                                if (e === 'PLC') {
                                  this.state.hardware_configs.modbus_03[index].parity = 0;
                                } else {
                                  this.state.hardware_configs.modbus_03[index].parity = 2;
                                }
                              } else {
                                this.state.hardware_configs.modbus_03[index] = {};
                                this.state.hardware_configs.modbus_03[index].type = e;
                                if (e === 'PLC') {
                                  this.state.hardware_configs.modbus_03[index].parity = 0;
                                } else {
                                  this.state.hardware_configs.modbus_03[index].parity = 2;
                                }
                              }
                            } else {
                              this.state.hardware_configs.modbus_03.splice(index, 1, {
                                ...this.state.hardware_configs.modbus_03[index],
                                type: e,
                                parity: e === 'PLC' ? 0 : 2,
                              });
                            }
                            this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                          }}
                          style={{width: 200}}
                          value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type}>
                          {[{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                            key: 'SCL-61D-GTE50',
                            name: '汇中 SCL-61D(管径≥50mm)',
                          }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'}, {
                            key: 0,
                            name: '无',
                          }].map((item, key) => {
                            return (
                              <Option key={key}
                                      value={item.key}>{item.name}</Option>
                            );
                          })}
                        </Select>*/}
                        <span>
                            {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'}, {
                              key: 0,
                              name: '无',
                            }],o=>o.key===this.state.hardware_configs.modbus_03[index].type)&&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},

                              {
                              key: 0,
                              name: '无',
                            }],o=>o.key===this.state.hardware_configs.modbus_03[index].type).name}
                          </span>
                      </Form.Item>
                        <br/>
                        {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                        [{name: '别名', key: 'alias'}].map((item2, index2) => {
                          return <Fragment key={index2}>
                            <Form.Item

                              label={item2.name}
                            >
                              {/*<Input
                                disabled
                                value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.modbus_03) {
                                    this.state.hardware_configs.modbus_03 = [];
                                  }
                                  if (this.state.hardware_configs.modbus_03.length < 4) {
                                    if (this.state.hardware_configs.modbus_03[index]) {
                                      this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                    } else {
                                      this.state.hardware_configs.modbus_03[index] = {};
                                      this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.modbus_03.splice(index, 1, {
                                      ...this.state.hardware_configs.modbus_03[index],
                                      [item2.key]: e.target.value
                                    });
                                  }


                                  this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                }}
                              />*/}
                              <span>
                                {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                              </span>
                            </Form.Item>

                            <br/>

                          </Fragment>;

                        })
                        }
                      </Fragment>
                      {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                      [{name: '设备地址', key: 'slave_address'},
                        {name: '上传间隔(秒)', key: 'upload_interval'}, {
                        name: '波特率',
                        key: 'baudrate'
                      }].map((item2, index2) => {
                        return (this.state.hardware_configs.modbus_03[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                          <Fragment key={index2}>
                            <Form.Item

                              label={item2.name}
                            >
                              <InputNumber
                                disabled={item2.key === 'baudrate'}
                                value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.modbus_03) {
                                    this.state.hardware_configs.modbus_03 = [];
                                  }
                                  if (this.state.hardware_configs.modbus_03.length < 2) {
                                    if (this.state.hardware_configs.modbus_03[index]) {
                                      this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                    } else {
                                      this.state.hardware_configs.modbus_03[index] = {};
                                      this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                    }
                                  } else {
                                    this.state.hardware_configs.modbus_03.splice(index, 1, {
                                      ...this.state.hardware_configs.modbus_03[index],
                                      [item2.key]: e,
                                    });
                                  }


                                  this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                }}
                              />
                            </Form.Item>
                          </Fragment>;

                      })
                      }
                      {
                        this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                        <Form.Item

                          label={'检验方式'}
                        >
                          <Select
                            style={{width: '100px'}}
                            disabled={true}
                            value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index]['parity']}
                          >
                            {[{key: 0, name: 'None'}, {
                              key: 1,
                              name: 'Odd'
                            }, {key: 2, name: 'Event'}].map((item, key) => {
                              return (
                                <Option key={key}
                                        value={item.key}>{item.name}</Option>
                              )
                            })}
                          </Select>
                        </Form.Item>
                      }
                      <br/>
                      {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                      this.state.hardware_configs.modbus_03[index].type === 'PLC' &&
                      <Fragment><Form.Item
                        label="压力限定值(MPa)"
                      >

                        <InputNumber
                          value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].pressure_limit_value}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.modbus_03) {
                              this.state.hardware_configs.modbus_03 = [];
                            }
                            if (this.state.hardware_configs.modbus_03.length < 2) {
                              if (this.state.hardware_configs.modbus_03[index]) {
                                this.state.hardware_configs.modbus_03[index].pressure_limit_value = e;
                              } else {
                                this.state.hardware_configs.modbus_03[index] = {};
                                this.state.hardware_configs.modbus_03[index].pressure_limit_value = e;
                              }
                            } else {
                              this.state.hardware_configs.modbus_03.splice(index, 1, {
                                ...this.state.hardware_configs.modbus_03[index],
                                pressure_limit_value: e,
                              });
                            }


                            this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                          }}
                        />
                      </Form.Item>
                        <Form.Item
                          label=""
                        >

                          <Button type='primary' onClick={() => {
                            confirm({
                              title: '确定要下发吗?',
                              okText: '确定',
                              centered: true,
                              maskClosable: true,
                              okType: 'primary',
                              cancelText: '取消',
                              onOk() {
                                that.setState({
                                  modbusIndex: index,
                                }, function () {
                                  that.commonCommand('write_modbus/plc');
                                });

                              },
                            });

                          }}>立即下发</Button>
                        </Form.Item>
                      </Fragment>
                      }

                    </TabPane>;
                  })
                }
              </Tabs>
            </div>
          </Fragment>
        }


      </Fragment>


    </Form>;
  };
  saveConfig = () => {
    if(!Boolean(Number(this.state.templateId))){
      message.error('请选择站点类型');
      return false
    }
    let sendDate = {}
    const parseConfig = JSON.parse(JSON.stringify(this.state.hardware_configs))
    if (parseConfig.device) {
      for (let i = 0; i < parseConfig.device.length; i++) {
        parseConfig.device[i].upload_interval = parseConfig.device[i].upload_interval * 60
      }
    }
    parseConfig.digital_output = [{}, {}];
    parseConfig.digital_output[0].enable = 0
    parseConfig.digital_output[1].enable = 0
    if (parseConfig.sensor) {
      for (let i = 0; i < parseConfig.sensor.length; i++) {
        if (parseConfig.sensor[i] && parseConfig.sensor[i].type !== 0) {
          parseConfig.sensor[i].over_cancel = parseConfig.sensor[i].over
          parseConfig.sensor[i].under_cancel = parseConfig.sensor[i].under
        }

      }
    }
    // sendDate.hardware_configs.modbus=this.state.hardware_configs.modbus_03
    // delete parseConfig.modbus_04;
    sendDate.hardware_configs = parseConfig;
    sendDate.hardware_configs.modbus = parseConfig.modbus_03;
    sendDate.template=Number(this.state.templateId)
    delete parseConfig.modbus_03;

    const that = this;
    console.log('sendDate', sendDate)
    request(`/workstations/${this.props.editRecord.id}/config`, {
      method: 'PUT',
      data: sendDate
    }).then((response) => {
      if (response.status === 200) {
        message.success('设置站点成功');
        that.props.onClose();
        that.props.onSearch()
      }

    })
  }
  render() {
    const formItemLayoutWithLabel = {
      labelCol: {
        xs: {span: 24},
        sm: {span: 6},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16},
      }
    };
    console.log(this.state.point)
    const {getFieldDecorator} = this.props.form;
    return (
      <div>
        {
          this.renderValveForm2()
        }

        <div
          style={{
            position: 'absolute',
            right: 0,
            bottom: 0,
            width: '100%',
            borderTop: '1px solid #e9e9e9',
            padding: '10px 16px',
            background: '#fff',
            textAlign: 'right',
            zIndex:'99'
          }}
        >
          <Button onClick={this.props.onClose} style={{ marginRight: 8 }}>
            取消
          </Button>
          <Button onClick={()=>{
            this.saveConfig();
          }} type="primary">
            确定
          </Button>
        </div>
      </div>
    );
  }
}

const AddPoliciesFormWrap = Form.create()(AddPoliciesForm);
export default connect()(AddPoliciesFormWrap);
